<?php
/*
 * add google site verification
 */
add_action('wp_head', 'google_site_verification', 1);
function google_site_verification() {
	echo '<meta name="google-site-verification" content="a27WEc1-f60VRKPOp8IPF8bdC9OZ6l9JfnTj_j9ZGGU" />';
}

/*
 * add js & style files into header
 */
wp_enqueue_style('niviostyledefault', THEME_URI . 'js/nivio/default.css',
		array(), '1.0');

wp_enqueue_style('niviostyle', THEME_URI . 'js/nivio/nivo-slider.css', array(),
		'2.6');

wp_enqueue_script('nivioslider',
		THEME_URI . 'js/nivio/jquery.nivo.slider.pack.js',
		array(
			'jquery'
		), '2.6');
wp_enqueue_script('hoverIntent',
		THEME_URI . 'js/jquery.hoverIntent.minified.js',
		array(
			'nivioslider'
		), 'r6');

wp_enqueue_script('vnwpjs', THEME_URI . 'js/vnwpjs.js',
		array(
			'nivioslider'
		), get_bloginfo('version'));

/*
 * output logo, search box, social icons
 */
remove_action('thematic_header', 'thematic_blogtitle', 3);

function childtheme_override_brandingopen() {
}

function childtheme_override_blogtitle() {
}

function childtheme_override_blogdescription() {
}

function childtheme_override_brandingclose() {
}

/**
 * Attach CSS3PIE behavior to elements
 * Add elements here that need PIE applied
 */
function render_ie_pie() {
	echo '
		<!--[if lt IE 9]>
		<link rel="stylesheet" type="text/css" href="' . THEME_URI
			. 'css/ie.css" />
		<style type="text/css" media="screen">
		   #main, .img-shadow, #slider{
		   		behavior: url(' . THEME_URI
			. 'inc/PIE.php)
		   }
		</style>
		<![endif]-->';
}
add_action('wp_head', 'render_ie_pie', 10);

add_filter('thematic_search_form', 'filter_search_form');
/*
 * filter search form
 */
function filter_search_form($form) {
	return str_replace('"Search"', '""', $form);
}

add_action('thematic_header', 'output_header', 1);
/*
 * output header
 */
function output_header() {
	echo '<div id="logo" >';
	echo '<a rel="home" title="' . get_bloginfo('desc') . '" href="'
			. get_bloginfo('url') . '">';
	echo '<img alt="' . get_bloginfo('desc') . '" src='
			. get_bloginfo('stylesheet_directory') . '/images/logo.png' . ' />';
	echo '</a>';
	echo '<div id="searchbox" class="right">';
	thematic_search_form();
	echo '</div><!--#searchbox-->';
	echo '<ul id="social_button">';
	echo '<li>';
	echo '<a title="' . __('Follow me on facebook', DOMAIN_TRANS)
			. '" href="http://www.facebook.com/vnwpthemes.com">'
			. get_img_src('facebook.png',
					__('Follow me on facebook', DOMAIN_TRANS)) . '</a>';
	echo '</li>';
	echo '<li>';
	echo '<a title="' . __('Follow me on twitter', DOMAIN_TRANS)
			. '" href="http://www.twitter.com/vnwpthemes.com">'
			. get_img_src('twitter.png',
					__('Follow me on twitter', DOMAIN_TRANS)) . '</a>';
	echo '</li>';
	echo '<li>';
	echo '<a title="' . __('RSS Feed', DOMAIN_TRANS) . '" href="' . get_bloginfo('rss2_url') .'">'
			. get_img_src('feed.png', __('RSS Feed', DOMAIN_TRANS)) . '</a>';
	echo '</li>';
	echo '</ul>';
	echo "</div><!--#logo-->";
}

/*
 * output slider html 
 */
function output_slider() {
	if (!is_home())
		return;
	echo '<div id="sliderwrapper">';
	echo '<div class="left">';
	echo '</div><!--.left-->';
	echo '<div id="slidercontent">';
	echo '<div id="about" class="left">';
	$id = get_option(THEME_NAME . '_about_page');
	$p = get_post($id);
	if($p){
		echo '<h1><span></span>' . $p->post_title .'</h1>';
		if (has_post_thumbnail($p->ID)) {
			$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($p->ID),
					'full');
			echo get_timthumb_img_src($thumb[0], 112, 87, $p->post_title,
					'img-shadow', $p->post_title);
		}
		echo '<p>';
		echo $p->post_content;
		echo '</p>';
	}
	echo '</div><!--#about-->';
	echo '<div id="feature" class="right slider">';
	echo '<div id="slider" class="nivoSlider">';
	//get posts & show
	global $wp_query;
	$slider_cat = get_option(THEME_NAME . '_feature_slider_cat', 1);
	$showposts = get_option(THEME_NAME . '_feature_slider_showposts', 5);
	$temp = $wp_query;
	$agrs = array(
		'cat'	=>	$slider_cat,
		'showposts' => $showposts,
		'orderby' => 'rand'
	);
	$wp_query = new WP_Query($agrs);
	if (have_posts()) {
		while (have_posts()) {
			the_post();
			echo '<a title="' . get_the_title() . '" href="' . get_permalink()
					. '">';
			if (has_post_thumbnail()) {
				$thumb = wp_get_attachment_image_src(get_post_thumbnail_id(),
						'full');
				echo get_timthumb_img_src($thumb[0], 565, 245, get_the_title(),
						'', get_the_title());
			}
			echo '</a>';
		}
	}
	$wp_query = null;
	$wp_query = $temp;
	wp_reset_query();
	//
	echo '</div><!--#slider-->';
	echo '<div id="buttons">';
	
	echo '</div><!--#buttons-->';
	echo '</div><!--#feature-->';
	echo '</div><!--#slidercontent-->';
	echo '<div class="right">';
	echo '</div><!--.right-->';
	echo '</div><!--#sliderwrapper-->';
}
add_action('thematic_abovecontainer', 'output_slider', 1);

